0.6.2-dev0
FORCES
FORtran lib for Comp. Env. Sys.
Loading...
Searching...
No Matches
mo_percentile::n_element Interface Reference

Nth smallest value in array. More...

Public Member Functions

real(dp) function n_element_dp (idat, n, mask, before, after, previous, next)
 
real(sp) function n_element_sp (idat, n, mask, before, after, previous, next)
 

Detailed Description

Nth smallest value in array.

Returns the n-th smallest value in an array.

If an optinal mask is given, values only on those locations that correspond to true values in the mask are used.

Example

vec = (/ 1.,2.,3.,4.,5.,6.,7.,8.,9.,10. /)
! Returns 4
out = n_element(vec,4)

See also example in test directory.

Literature

  1. Niklaus Wirth. _"Algorithms and Data Structures"_. Prentice-Hall, Inc., 1985. ISBN 0-13-022005-1.
Parameters
[in]real(sp/dp) :: vec(:)1D-array with input numbers
[in]integer(i4), optional :: nIndex of sorted array
[in]logical, optional :: mask(:)1D-array of logical values with size(vec). If present, only those locations in vec corresponding to the true values in mask are used.
[out]real(sp/dp) :: before(n-1)-th smallest value in input array, e.g. for median/percentile calculations
[out]real(sp/dp) :: previousSame as before
[out]real(sp/dp) :: after(n+1)-th smallest value in input array
[out]real(sp/dp) :: nextSame as after
Return values
real(sp/dp) :: outN-th smallest value in input array
Author
Matthias Cuntz
Date
May 2014
  • based on qmedian

Definition at line 109 of file mo_percentile.f90.

Member Function/Subroutine Documentation

◆ n_element_dp()

real(dp) function mo_percentile::n_element::n_element_dp ( real(dp), dimension(:), intent(in)  idat,
integer(i4), intent(in)  n,
logical, dimension(:), intent(in), optional  mask,
real(dp), intent(out), optional  before,
real(dp), intent(out), optional  after,
real(dp), intent(out), optional  previous,
real(dp), intent(out), optional  next 
)

Definition at line 308 of file mo_percentile.f90.

◆ n_element_sp()

real(sp) function mo_percentile::n_element::n_element_sp ( real(sp), dimension(:), intent(in)  idat,
integer(i4), intent(in)  n,
logical, dimension(:), intent(in), optional  mask,
real(sp), intent(out), optional  before,
real(sp), intent(out), optional  after,
real(sp), intent(out), optional  previous,
real(sp), intent(out), optional  next 
)

Definition at line 383 of file mo_percentile.f90.


The documentation for this interface was generated from the following file: