FINDLOC

Platform

x64, Win32

Purpose

To get the first position in an array where the element has a given value.

Class

Transformational function.

Syntax

INTEGER FUNCTION FINDLOC(ARRAY, VALUE,  DIM [, MASK])
INTEGER FUNCTION FINDLOC(ARRAY, VALUE [, MASK])
INTEGER DIM
LOGICAL MASK

Description

ARRAY is an integer or real array. DIM is a scalar integer in the range 1 < DIM < n where n is the rank of ARRAY. MASK is a logical array that is conformable with ARRAY.

Return value

This function determines the location in the ARRAY along dimension DIM with the value VALUE, for which the elements of MASK are TRUE.

If DIM is not present, the result is an array of rank one and size n, otherwise the result is of rank n - 1 and has a shape that is the same as that of ARRAY but omitting dimension DIM.

Example

The value of FINDLOC ([2, 6, 4, 6], VALUE = 6) is [2].

If A has the value
      [ 0 -5 7 7 ]
      [ 3 4 -1 2 ]
      [ 1 5  6 7 ]
and M has the value
      [ T T F T ]
      [ T T F T ]
      [ T T F T ]
then FINDLOC (A, 7, MASK = M) is [1, 4].

The value of FINDLOC ([2, 6, 4], VALUE = 6, DIM = 1) is 2.

If A has the value

      [ 1 2 -9 ]
      [ 2 3  6 ]
then FINDLOC (A, VALUE = 2, DIM = 1) is [2, 1, 0] and FINDLOC (A, VALUE = 2, DIM = 2) is [2, 1].

Notes

This function was introduced in the Fortran 2008 standard and is similar to MINLOC. When fully implemented it will include additional arguments: KIND and BACK.

 

 

Basket
Empty
 
Copyright © 1999-2024 Silverfrost Limited