[J3] Commutativity of co_reduce
Malcolm Cohen
malcolm at nag-j.co.jp
Thu Oct 24 02:22:22 UTC 2024
Hi Brad,
Bare string concatenation is not possible, as the character length of the OPERATION is the same as the length of the arguments, not the sum. I also don't think that string concatenation is a mathematical operation per se.
Bare matrix multiplication is likewise not possible, as the arguments of OPERATION are scalar, but you are right that the matrices could be wrapped in a derived type.
I seem to recall that commutativity was in an earlier draft, but that we took it out as all the intrinsic operations that are not commutative are also not associative. This was quite a while ago. Of course we deliberately took it out of REDUCE as there is an ordering available.
I will write a paper.
Cheers,
--
..............Malcolm Cohen, NAG Oxford/Tokyo.
-----Original Message-----
From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of Brad Richardson via J3
Sent: Wednesday, October 23, 2024 10:27 AM
To: General J3 interest list <j3 at mailman.j3-fortran.org>
Cc: Brad Richardson <everythingfunctional at protonmail.com>; Malcolm Cohen <malcolm at nag-j.co.jp>
Subject: Re: [J3] Commutativity of co_reduce
Hi Malcolm,
String concatenation is the easiest example to think of. Matrix multiplication is another. The possibility of encountering them gets much greater when you start considering user defined derived types.
Regards,
Brad
On Wed, 2024-10-23 at 10:17 +0900, Malcolm Cohen via J3 wrote:
> Hi Brad,
>
> What operation is associative but not commutative?
>
> Also, the answer is not deterministic anyway: the rule is
> "mathematically associative" not "computationally associative".
>
> Cheers,
> --
> ..............Malcolm Cohen, NAG Oxford/Tokyo.
>
> -----Original Message-----
> From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of Brad
> Richardson via J3
> Sent: Wednesday, October 23, 2024 9:47 AM
> To: General J3 interest list <j3 at mailman.j3-fortran.org>
> Cc: Brad Richardson <everythingfunctional at protonmail.com>;
> fortran at lbl.gov
> Subject: [J3] Commutativity of co_reduce
>
> Hi all,
>
> The LBL group has encountered another question, this time with respect
> to co_reduce. At present the description of OPERATION argument states
> "OPERATION shall implement a mathematically associative operation."
> The subsequent description of how OPERATION is applied:
>
> The computed value of a reduction operation over a set of values is
> the result of an iterative process. Each iteration involves the
> evaluation of OPERATION (x, y) for x and y in the set, the removal of
> x and y from the set, and the addition of the value of OPERATION (x,
> y) to the set.
> The process terminates when the set has only one element; this is the
> computed value.
>
> Of note is that the word "set" implies that there is no ordering of
> the values. The description also does not imply an order in which the
> values are combined nor does it specify what subsequent iteration
> consumes the result of a given combination. Thus the reduction only
> has a deterministic answer if OPERATION is both associative *and*
> commutative. We believe that it would be clearer if this requirement
> was stated explicitly. The edits for this would be quite simple. I.e.
>
> [383:5] Add "and commutative" after "associative" so that the sentence
> reads:
>
> OPERATION shall implement a mathematically associative and
> commutative operation.
>
> [383:29+] Delete the NOTE
>
> Do others have opinions? Would it be reasonable to submit this change
> as an edits paper as just a clarifying change?
>
> Regards,
> Brad Richardson
>
>
More information about the J3
mailing list