Hi All,

Now that the reduce intrinsic seems to be OK on all platforms, I thought
that it was time to catch up with the documentation.

The attached produces good .html without any additional warnings or errors
using texi2any and ~/share/info/gfortran.info is as intended.

OK for mainline?

Paul
diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi
index 8c160e58b00..6fa6fc278be 100644
--- a/gcc/fortran/intrinsic.texi
+++ b/gcc/fortran/intrinsic.texi
@@ -270,6 +270,7 @@ Some basic guidelines for editing this document:
 * @code{RANGE}:         RANGE,     Decimal exponent range
 * @code{RANK} :         RANK,      Rank of a data object
 * @code{REAL}:          REAL,      Convert to real type 
+* @code{REDUCE}:        REDUCE,    Reduction of an array with a user function
 * @code{RENAME}:        RENAME,    Rename a file
 * @code{REPEAT}:        REPEAT,    Repeated string concatenation
 * @code{RESHAPE}:       RESHAPE,   Function to reshape an array
@@ -12410,6 +12411,107 @@ integers}).
 
 
 
+@node REDUCE
+@section @code{REDUCE} --- Reduction of an array with a user function
+@fnindex REDUCE
+@cindex array, change dimensions
+@cindex array, transmogrify
+
+@table @asis
+@item @emph{Synopsis}:
+@code{RESULT = REDUCE (ARRAY, OPERATION [, MASK, IDENTITY, ORDERED])}
+or
+@code{RESULT = REDUCE (ARRAY, OPERATION, DIM [, MASK, IDENTITY, ORDERED])}
+
+@item @emph{Description}:
+Reduces @var{ARRAY} using the scalar function @var{OPERATION}. If DIM 
+is not present the result is a scalar. Otherwise, the reduction takes 
+place along the dimension @var{DIM} and the result has a rank one less 
+than that of @var{ARRAY}. @var{MASK} is a logical array with the same 
+shape as @var{ARRAY}. If any elements of the reduction are empty, they 
+are filled by @var{IDENTITY}. @var{ORDERED} has no effect at present.
+
+@item @emph{Class}:
+Transformational function
+
+@item @emph{Arguments}:
+@multitable @columnfractions .15 .70
+@item @var{ARRAY} @tab Shall be an array of any type.
+@item @var{OPERATION} @tab Shall be a pure function with exactly two 
+arguments; each argument shall be a scalar, nonallocatable, 
+noncoarray, nonpointer, nonpolymorphic, nonoptional dummy data object 
+with the same declared type and type parameters as @var{ARRAY}. If one 
+argument has the ASYNCHRONOUS, TARGET, or VALUE attribute, the other 
+shall have that attribute. Its result shall be a nonpolymorphic scalar 
+and have the same declared type and type parameters as @var{ARRAY}. 
+@var{OPERATION} should implement a mathematically associative 
+operation. It need not be commutative.
+@item @var{DIM} @tab Shall be an integer scalar with a value in the 
+range 1 ≤ @var{DIM} ≤ n, where n is the rank of @var{ARRAY}.
+@item @var{MASK} @tab (Optional) shall be of type logical and shall be 
+conformable with @var{ARRAY}.
+@item @var{IDENTITY} @tab (Optional) shall be scalar with the same 
+declared type and type parameters as @var{ARRAY}.
+@item @var{ORDERED} @tab (Optional) shall be a logical scalar.
+@end multitable
+
+
+@item @emph{Return value}:
+The result is of the same declared type and type parameters as 
+@var{ARRAY}. It is scalar if @var{DIM} does not appear; otherwise, the 
+result has rank n − 1 and shape [d1, d2, . . . , d@var{DIM}−1, 
+d@var{DIM}+1, . . . , dn] where [d1, d2, . . . , dn] is the shape of 
+@var{ARRAY}.
+
+Case (i): The result of @code{REDUCE (ARRAY, OPERATION [, IDENTITY = 
+IDENTITY, ORDERED = ORDERED])} over the sequence of values in 
+@var{ARRAY} is the result of an iterative process. The initial order 
+of the sequence is array element order. While the sequence has more 
+than one element, each iteration involves the execution of @code{r 
+= OPERATION(x, y)} for adjacent x and y in the sequence, with x 
+immediately preceding y, and the subsequent replacement of x and y 
+with r; if @var{ORDERED} is present with the value true, x and y shall 
+be the first two elements of the sequence. The process continues until 
+the sequence has only one element which is the value of the reduction. 
+If the initial sequence is empty, the result has the value 
+@var{IDENTITY} if @var{IDENTITY} is present, and otherwise, error 
+termination is initiated.
+
+Case (ii): The result of @code{REDUCE (ARRAY, OPERATION, MASK = MASK 
+[, IDENTITY = IDENTITY, ORDERED = ORDERED])} is as for Case (i) except 
+that the initial sequence is only those elements of @var{ARRAY} for 
+which the corresponding elements of @var{MASK} are true.
+
+Case (iii): If @var{ARRAY} has rank one, @code{REDUCE (ARRAY, 
+OPERATION, DIM = DIM [, MASK = MASK, IDENTITY = IDENTITY, ORDERED = 
+ORDERED])} has a value equal to that of @code{REDUCE (AR41 RAY, 
+OPERATION [, MASK = MASK, IDENTITY = IDENTITY, ORDERED = ORDERED])}. 
+Otherwise, the value of element (s1, s2, . . . , sDIM−1, sDIM+1, . . . 
+, sn) of @code{REDUCE (ARRAY, OPERATION, DIM = DIM [, MASK = MASK, 
+IDENTITY = IDENTITY, ORDERED = ORDERED])} is equal to @code{REDUCE 
+(ARRAY (s1, s2, . . . , sDIM−1, :, sDIM+1, . . . , sn), OPERATION = 
+OPERATION, DIM=1[, MASK = MASK (s1, s2, . . . , sDIM−1, :, sDIM+1, . . 
+. , sn), IDENTITY = IDENTITY, ORDERED = ORDERED] )}.
+
+NOTE
+If @var{OPERATION} is not computationally associative, @var{REDUCE} 
+without @code{ORDERED=.TRUE.} with the same argument values might not 
+always produce the same result, as the processor can apply the 
+associative law to the evaluation.
+
+@item @emph{Example}:
+@smallexample
+The following examples all use the function MY_MULT, which returns the product of its two integer arguments.
+Case (i): The value of @code{REDUCE ([1, 2, 3], MY_MULT)} is 6.
+Case (ii): @code{REDUCE (C, MY_MULT, MASK= C > 0, IDENTITY=1)} forms the product of the positive elements of C.
+Case (iii): If B is the array [1 3 5; 2 4 6] , @code{REDUCE (B, MY_MULT, DIM = 1)} is [2, 12, 30] and @code{REDUCE (B, MY_MULT, DIM = 2)} is [15, 48].
+@end smallexample
+@item @emph{Standard}:
+Fortran 2018
+@end table
+
+
+
 @node RENAME
 @section @code{RENAME} --- Rename a file
 @fnindex RENAME

Reply via email to