To: J3 J3/15-170
Subject: Extensions to FINDLOC
From: Van Snyder
Reference: 15-007r1
Date: 2015 June 07
1. First Proposal
==================
So that processors may use a secant method or binary search to improve
the performance of FINDLOC, add an optional ORDERED argument. If
ORDERED is present and its value is true, and ARRAY is of rank one or
DIM is present, and ARRAY is of type integer, real, or character, the
elements of ARRAY shall be ordered in either ascending or descending
order. Processors could exploit this property to use a binary search or
secant method, either of which can be significantly faster than a linear
search, especially for large arrays.
2. Draft Edits for First Proposal
==================================
[327 Table 13.1] In the entry for FINDLOC, after BACK insert ",
ORDERED" twice.
[359:11 13.8.71] After BACK insert ", ORDERED" twice.
[359:15 13.8.71p3] Within the description of ARRAY append a sentence:
"If ORDERED is present and its value is true, and ARRAY is of rank one
or DIM is present, and ARRAY is of type integer, real, or character, the
values of ARRAY shall be in either ascending or descending order."
[359:21+ 13.8.71p3] After the description of BACK insert
"ORDERED (optional) shall be a logical scalar."
3. Second Proposal
=================
Allow the ARRAY argument to be of any type. If it is of derived type,
require that it have a type-bound OPERATOR(==).
4. Draft Edits for Second Proposal
=================================
[359:15 13.8.71p3] Within the description of ARRAY replace " of
intrinsic type" with ". If ARRAY is of derived type, OPERATOR(==) shall
be bound to the type of ARRAY and shall be accessible. The first
operand of OPERATOR(==) shall be a scalar that is type compatible with
ARRAY; the second shall be a scalar that is type compatible with VALUE;
the result of OPERATOR(==) shall be a scalar of type logical."
[359:17 13.8.71p3] Within the description of VALUE replace ".EQV.." with
".EQV. if ARRAY is of intrinsic type, or a scalar that is suitable for
use as the second operand of the OPERATOR(==) bound to the type of ARRAY
if an element of ARRAY is the first operand."
5. Draft Edits for First Proposal if second proposal is also accepted
=====================================================================
[327 Table 13.1] In the entry for FINDLOC, after BACK insert ",
ORDERED" twice.
[359:11 13.8.71] After BACK insert ", ORDERED" twice.
[359:15 13.8.71p3] Within the description of ARRAY append a sentence:
"If ORDERED is present and its value is true, and ARRAY is of rank one
or DIM is present, and ARRAY is of type integer, real, character, or a
derived type for which type-bound OPERATOR(<=), OPERATOR(==) and
OPERATOR(>=) are accessible and can be invoked with scalars of the
dynamic types of ARRAY and VALUE, the values of ARRAY shall be in either
ascending or descending order, as defined by intrinsic <= or >=
operators, or type-bound OPERATOR(<=) or OPERATOR(>=)."
[359:21+ 13.8.71p3] After the description of BACK insert
"ORDERED (optional) shall be a logical scalar."
[360:12+ 13.8.71p8+] Insert a NOTE:
"NOTE 13.12a
If ORDERED is present with the value true and ARRAY is of derived type,
but the type of ARRAY does not have type-bound OPERATOR(<=) and
OPERATOR(>=) suitable for use with a scalar first operand of the dynamic
type of ARRAY and a second scalar operand of the dynamic type of VALUE,
a processor will not be able to exploit the ordered nature of ARRAY to
improve performance."
{Since elements of polymorphic arrays are of homogeneous type, a processor
can determine the correct OPERATOR(<=), OPERATOR(==), and OPERATOR(>=) to
use when ARRAY is polymorphic. A processor's implementation might be such
that it does not need both OPERATOR(<=) and OPERATOR(>=), but the standard
should be silent on this score.}