j3-fortran / fortran_proposals

Proposals for the Fortran Standard Committee
178 stars 15 forks source link

Add simple sorting intrinsics #258

Open w6ws opened 2 years ago

w6ws commented 2 years ago

Most languages have sorting procedures in their libraries, and some even have them as operators. Various Fortran implementations have had sorting procedures in their libraries for many many years - yet none are called in a standardized way. Another approach might be to use C Interop to call C's qsort. However it is not as user-friendly as simply calling an intrinsic. It also has performance problems due to the lack of inlining of the required comparison procedure.

I'd like to propose two sets of simple intrinsic functions that accept 1D array arguments of intrinsic types (e.g., integers, reals, and character strings - maybe logicals), and either return a sorted version of the input, or an integer permutation vector ("grade"). The latter should have an optional argument for stability. Using the old HPF function names as examples, but minus HPF's funky DIM= argument:

result = GRADE_DOWN (ARG[, STABLE=logical_scalar]) ! returns permutation vector for accessing input in descending order result = GRADE_UP (ARG[, STABLE=logical_scalar]) ! returns permutation vector for accessing input in ascending order

result = SORT_DOWN (ARG) ! returns input in descending order result = SORT_UP (ARG) ! returns input in ascending order

I like having them in functional form for use in expressions. However I could see also adding intrinsic subroutine versions of SORT_[UP|DOWN] for doing in-place sorts. For example:

call SORT_INPLACE_DOWN (ARG) call SORT_INPLACE_UP (ARG)

The GRADE versions are especially useful with sorting arrays of derived types. Once the permutation vector has been obtained, the individual elements can be accessed or permuted as needed:

type(mytype_t), allocatable :: my_array(:), my_sorted_array(:) integer, allocatable :: perm_vector(:) : perm_vector = GRADE_UP (my_array%key_value) my_sorted_array = my_array(perm_vector)

or even:

my_sorted_array = my_array(GRADE_UP (my_array%key_value))

wyphan commented 2 years ago

If I remember correctly, this is already implemented as part of the Fortran standard library fortran-lang/stdlib

On Sun, Apr 24, 2022, 12:24 Walter Spector @.***> wrote:

Most languages have sorting procedures in their libraries, and some even have them as operators. Various Fortran implementations have had sorting procedures in their libraries for many many years - yet none are called in a standardized way. Another approach might be to use C Interop to call C's qsort. However it is not as user-friendly as simply calling an intrinsic. It also has performance problems due to the lack of inlining of the required comparison procedure.

I'd like to propose two sets of simple intrinsic functions that accept 1D array arguments of intrinsic types (e.g., integers, reals, and character strings - maybe logicals), and either return a sorted version of the input, or an integer permutation vector ("grade"). The latter should have an optional argument for stability. Using the old HPF function names as examples, but minus HPF's funky DIM= argument:

result = GRADE_DOWN (ARG[, STABLE=logical_scalar]) ! returns permutation vector for accessing input in descending order result = GRADE_UP (ARG[, STABLE=logical_scalar]) ! returns permutation vector for accessing input in ascending order

result = SORT_DOWN (ARG) ! returns input in descending order result = SORT_UP (ARG) ! returns input in ascending order

I like having them in functional form for use in expressions. However I could see also adding intrinsic subroutine versions of SORT_[UP|DOWN] for doing in-place sorts. For example:

call SORT_INPLACE_DOWN (ARG) call SORT_INPLACE_UP (ARG)

The GRADE versions are especially useful with sorting arrays of derived types. Once the permutation vector has been obtained, the individual elements can be accessed or permuted as needed:

type(mytype_t), allocatable :: my_array(:), my_sorted_array(:) integer, allocatable :: perm_vector(:) : perm_vector = GRADE_UP (my_array%key_value) my_sorted_array = my_array(perm_vector)

or even:

my_sorted_array = my_array(GRADE_UP (my_array%key_value))

— Reply to this email directly, view it on GitHub https://github.com/j3-fortran/fortran_proposals/issues/258, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMERY5HRW4AVIE5KKZRIFNLVGVYSZANCNFSM5UGOXWPQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

w6ws commented 2 years ago

Hi,   Yes there are sorting procedures there.  I made a few suggestions on them - some of which were accepted.  However this proposal differs a bit in a few ways.  In particular using a functional form so they can be used in expressions.   Walter   -----Original Message----- From: j3-fortran/fortran_proposals Sent: Apr 24, 2022 9:33 AM To: j3-fortran/fortran_proposals Cc: Walter Spector , Author Subject: Re: [j3-fortran/fortran_proposals] Add simple sorting intrinsics (Issue #258)     If I remember correctly, this is already implemented as part of the Fortran standard library fortran-lang/stdlib.

On Sun, Apr 24, 2022, 12:24 Walter Spector @.***> wrote:

Most languages have sorting procedures in their libraries, and some even have them as operators. Various Fortran implementations have had sorting procedures in their libraries for many many years - yet none are called in a standardized way. Another approach might be to use C Interop to call C's qsort. However it is not as user-friendly as simply calling an intrinsic. It also has performance problems due to the lack of inlining of the required comparison procedure.

I'd like to propose two sets of simple intrinsic functions that accept 1D array arguments of intrinsic types (e.g., integers, reals, and character strings - maybe logicals), and either return a sorted version of the input, or an integer permutation vector ("grade"). The latter should have an optional argument for stability. Using the old HPF function names as examples, but minus HPF's funky DIM= argument:

result = GRADE_DOWN (ARG[, STABLE=logical_scalar]) ! returns permutation vector for accessing input in descending order result = GRADE_UP (ARG[, STABLE=logical_scalar]) ! returns permutation vector for accessing input in ascending order

result = SORT_DOWN (ARG) ! returns input in descending order result = SORT_UP (ARG) ! returns input in ascending order

I like having them in functional form for use in expressions. However I could see also adding intrinsic subroutine versions of SORT_[UP|DOWN] for doing in-place sorts. For example:

call SORT_INPLACE_DOWN (ARG) call SORT_INPLACE_UP (ARG)

The GRADE versions are especially useful with sorting arrays of derived types. Once the permutation vector has been obtained, the individual elements can be accessed or permuted as needed:

type(mytype_t), allocatable :: my_array(:), my_sorted_array(:) integer, allocatable :: perm_vector(:) : perm_vector = GRADE_UP (my_array%key_value) my_sorted_array = my_array(perm_vector)

or even:

my_sorted_array = my_array(GRADE_UP (my_array%key_value))

— Reply to this email directly, view it on GitHub , or unsubscribe

. You are receiving this because you are subscribed to this thread.Message ID: @.***>

— Reply to this email directly, view it on GitHub (https://github.com/j3-fortran/fortran_proposals/issues/258#issuecomment-1107874818), or unsubscribe (https://github.com/notifications/unsubscribe-auth/ABCNQO74URLDZWPFTRQOQRDVGVZVZANCNFSM5UGOXWPQ). You are receiving this because you authored the thread.Message ID:

 

wyphan commented 2 years ago

The DIM= argument can be optional. Then the GRADE_DOWN and GRADE_UP intrinsic functions can be made ELEMENTAL so it applies to arrays. Maybe add an AXIS= argument too to indicate which dimensions of the array will be sorted.

w6ws commented 2 years ago

I found the DIM= in the original HPF specs to be confusing and ultimately not very useful.  It just complicated, both from an implementation and usability point of view, what should have been a very simple API.  So I'm not personally a proponent of it.   Walter   -----Original Message----- From: j3-fortran/fortran_proposals Sent: Apr 24, 2022 9:49 AM To: j3-fortran/fortran_proposals Cc: Walter Spector , Author Subject: Re: [j3-fortran/fortran_proposals] Add simple sorting intrinsics (Issue #258)     The DIM= argument can be optional. Then the GRADE_DOWN and GRADE_UP intrinsic functions can be made ELEMENTAL so it applies to arrays. Maybe add an AXIS= argument too to indicate which dimensions of the array will be sorted. — Reply to this email directly, view it on GitHub (https://github.com/j3-fortran/fortran_proposals/issues/258#issuecomment-1107877182), or unsubscribe (https://github.com/notifications/unsubscribe-auth/ABCNQO2D5WZHQ5AEHH42QQLVGV3QNANCNFSM5UGOXWPQ). You are receiving this because you authored the thread.Message ID:

 

womenflyplanes commented 2 years ago

Mathematical definitions are in my dissertation. If you’d like to speak to the original designer and implementor grade up and down in APL It is Luther Woodrum and he can be reached at lex@skyelogic.org

w6ws commented 2 years ago

LOL!  Yes, I learned a bit about APL back in college (on a DECsystem-10).  My copy of the classic Sandra Pakin APL/360 manual from those days uses the terms "grade up" and "grade down" for the respective operators.  So I thought it was fun that the HPF group used the same for their functions.  It is also interesting that HPF 1 only had the grade functions.  HPF 2.0 added the sort functions.   I also have a copy of Ken Iversons "A Programming Language".  It has quite a lot of prose on ranking and sorting, but doesn't specifically use those terms.   Walter   -----Original Message----- From: j3-fortran/fortran_proposals Sent: Apr 24, 2022 10:00 AM To: j3-fortran/fortran_proposals Cc: Walter Spector , Author Subject: Re: [j3-fortran/fortran_proposals] Add simple sorting intrinsics (Issue #258)     Mathematical definitions are in my dissertation. If you’d like to speak to the original designer and implementor grade up and down in APL It is Luther Woodrum and he can be reached at @. @.) — Reply to this email directly, view it on GitHub (https://github.com/j3-fortran/fortran_proposals/issues/258#issuecomment-1107878967), or unsubscribe (https://github.com/notifications/unsubscribe-auth/ABCNQO35Q4BDQOVONHV2BV3VGV44TANCNFSM5UGOXWPQ). You are receiving this because you authored the thread.Message ID:

 

womenflyplanes commented 2 years ago

Like I said , contact Luther for history and details.

On Sun, Apr 24, 2022 at 1:21 PM Walter Spector @.***> wrote:

LOL! Yes, I learned a bit about APL back in college (on a DECsystem-10). My copy of the classic Sandra Pakin APL/360 manual from those days uses the terms "grade up" and "grade down" for the respective operators. So I thought it was fun that the HPF group used the same for their functions. It is also interesting that HPF 1 only had the grade functions. HPF 2.0 added the sort functions.

I also have a copy of Ken Iversons "A Programming Language". It has quite a lot of prose on ranking and sorting, but doesn't specifically use those terms.

Walter

-----Original Message----- From: j3-fortran/fortran_proposals Sent: Apr 24, 2022 10:00 AM To: j3-fortran/fortran_proposals Cc: Walter Spector , Author Subject: Re: [j3-fortran/fortran_proposals] Add simple sorting intrinsics (Issue #258)

Mathematical definitions are in my dissertation. If you’d like to speak to the original designer and implementor grade up and down in APL It is Luther Woodrum and he can be reached at @. @.) — Reply to this email directly, view it on GitHub ( https://github.com/j3-fortran/fortran_proposals/issues/258#issuecomment-1107878967), or unsubscribe ( https://github.com/notifications/unsubscribe-auth/ABCNQO35Q4BDQOVONHV2BV3VGV44TANCNFSM5UGOXWPQ ). You are receiving this because you authored the thread.Message ID:

— Reply to this email directly, view it on GitHub https://github.com/j3-fortran/fortran_proposals/issues/258#issuecomment-1107882708, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABVSNFA3B5YDWLJ6TWVCAL3VGV7LFANCNFSM5UGOXWPQ . You are receiving this because you commented.Message ID: @.***>

-- "Great spirits have always encountered violent opposition from mediocre minds" - Albert Einstein

womenflyplanes commented 2 years ago

That’s because it was Luther’s idea not Kens. That’s why it’s not in kens book .

On Sun, Apr 24, 2022 at 1:21 PM Walter Spector @.***> wrote:

LOL! Yes, I learned a bit about APL back in college (on a DECsystem-10). My copy of the classic Sandra Pakin APL/360 manual from those days uses the terms "grade up" and "grade down" for the respective operators. So I thought it was fun that the HPF group used the same for their functions. It is also interesting that HPF 1 only had the grade functions. HPF 2.0 added the sort functions.

I also have a copy of Ken Iversons "A Programming Language". It has quite a lot of prose on ranking and sorting, but doesn't specifically use those terms.

Walter

-----Original Message----- From: j3-fortran/fortran_proposals Sent: Apr 24, 2022 10:00 AM To: j3-fortran/fortran_proposals Cc: Walter Spector , Author Subject: Re: [j3-fortran/fortran_proposals] Add simple sorting intrinsics (Issue #258)

Mathematical definitions are in my dissertation. If you’d like to speak to the original designer and implementor grade up and down in APL It is Luther Woodrum and he can be reached at @. @.) — Reply to this email directly, view it on GitHub ( https://github.com/j3-fortran/fortran_proposals/issues/258#issuecomment-1107878967), or unsubscribe ( https://github.com/notifications/unsubscribe-auth/ABCNQO35Q4BDQOVONHV2BV3VGV44TANCNFSM5UGOXWPQ ). You are receiving this because you authored the thread.Message ID:

— Reply to this email directly, view it on GitHub https://github.com/j3-fortran/fortran_proposals/issues/258#issuecomment-1107882708, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABVSNFA3B5YDWLJ6TWVCAL3VGV7LFANCNFSM5UGOXWPQ . You are receiving this because you commented.Message ID: @.***>

-- "Great spirits have always encountered violent opposition from mediocre minds" - Albert Einstein

womenflyplanes commented 2 years ago

Ken never had indexing either. Luther was the first to introduce any kind of indexing in APL. BTW, he also has mucho patents on his sorting algorithms.

On Sun, Apr 24, 2022 at 1:37 PM Lenore Mullin @.***> wrote:

That’s because it was Luther’s idea not Kens. That’s why it’s not in kens book .

On Sun, Apr 24, 2022 at 1:21 PM Walter Spector @.***> wrote:

LOL! Yes, I learned a bit about APL back in college (on a DECsystem-10). My copy of the classic Sandra Pakin APL/360 manual from those days uses the terms "grade up" and "grade down" for the respective operators. So I thought it was fun that the HPF group used the same for their functions. It is also interesting that HPF 1 only had the grade functions. HPF 2.0 added the sort functions.

I also have a copy of Ken Iversons "A Programming Language". It has quite a lot of prose on ranking and sorting, but doesn't specifically use those terms.

Walter

-----Original Message----- From: j3-fortran/fortran_proposals Sent: Apr 24, 2022 10:00 AM To: j3-fortran/fortran_proposals Cc: Walter Spector , Author Subject: Re: [j3-fortran/fortran_proposals] Add simple sorting intrinsics (Issue #258)

Mathematical definitions are in my dissertation. If you’d like to speak to the original designer and implementor grade up and down in APL It is Luther Woodrum and he can be reached at @. @.) — Reply to this email directly, view it on GitHub ( https://github.com/j3-fortran/fortran_proposals/issues/258#issuecomment-1107878967), or unsubscribe ( https://github.com/notifications/unsubscribe-auth/ABCNQO35Q4BDQOVONHV2BV3VGV44TANCNFSM5UGOXWPQ ). You are receiving this because you authored the thread.Message ID:

— Reply to this email directly, view it on GitHub https://github.com/j3-fortran/fortran_proposals/issues/258#issuecomment-1107882708, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABVSNFA3B5YDWLJ6TWVCAL3VGV7LFANCNFSM5UGOXWPQ . You are receiving this because you commented.Message ID: @.***>

-- "Great spirits have always encountered violent opposition from mediocre minds" - Albert Einstein

-- "Great spirits have always encountered violent opposition from mediocre minds" - Albert Einstein

womenflyplanes commented 2 years ago

That's very funny. I was the one who first implemented mulidimensionaional arrays of more than two. All the ones before that were only for matrices, two dimensions.

I implemented 7 dimensions.

LW

On Sun, 24 Apr 2022, Lenore Mullin wrote:

Ken never had indexing either. Luther was the first to introduce any kind of indexing in APL.BTW, he also has mucho patents on his sorting algorithms.

On Sun, Apr 24, 2022 at 1:37 PM Lenore Mullin @.***> wrote: That’s because it was Luther’s idea not Kens. That’s why it’s not in kens book .

On Sun, Apr 24, 2022 at 1:21 PM Walter Spector @.***> wrote:

  LOL!  Yes, I learned a bit about APL back in college (on a
  DECsystem-10).  My copy of the classic Sandra Pakin
  APL/360 manual from those days uses the terms "grade up"
  and "grade down" for the respective operators.  So I
  thought it was fun that the HPF group used the same for
  their functions.  It is also interesting that HPF 1 only
  had the grade functions.  HPF 2.0 added the sort
  functions.
   
  I also have a copy of Ken Iversons "A Programming
  Language".  It has quite a lot of prose on ranking and
  sorting, but doesn't specifically use those terms.
   
  Walter
   
  -----Original Message-----
  From: j3-fortran/fortran_proposals
  Sent: Apr 24, 2022 10:00 AM
  To: j3-fortran/fortran_proposals
  Cc: Walter Spector , Author
  Subject: Re: [j3-fortran/fortran_proposals] Add simple
  sorting intrinsics (Issue #258)
   
   
  Mathematical definitions are in my dissertation. If you’d
  like to speak to the original designer and implementor
  grade up and down in APL It is Luther Woodrum and he can
  be reached at
  ***@***.*** ***@***.***)
  —
  Reply to this email directly, view it on GitHub(https://github.com/j3-fortran/fortran_proposals/issues/258#issuecomment-11
  07878967), or unsubscribe(https://github.com/notifications/unsubscribe-auth/ABCNQO35Q4BDQOVONHV2BV3V
  GV44TANCNFSM5UGOXWPQ).
  You are receiving this because you authored the
  thread.Message ID:

   

  —
  Reply to this email directly, view it on GitHub, or
  unsubscribe.
  You are receiving this because youcommented.[ABVSNFEJ7TVCTOPYCEAQSIDVGV7LFA5CNFSM5UGOXWP2YY3PNVWWK3TUL52HS4DF
  VREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOIIEPFVA.gif]
  Message ID:
  ***@***.***>

-- "Great spirits have always encountered violent opposition from mediocre minds" - Albert Einstein

-- "Great spirits have always encountered violent opposition from mediocre minds" - Albert Einstein

womenflyplanes commented 2 years ago

Exactly!

On Mon, Apr 25, 2022 at 8:40 AM Luther Woodrum @.***> wrote:

That's very funny. I was the one who first implemented mulidimensionaional arrays of more than two. All the ones before that were only for matrices, two dimensions.

I implemented 7 dimensions.

LW

On Sun, 24 Apr 2022, Lenore Mullin wrote:

Ken never had indexing either. Luther was the first to introduce any kind of indexing in APL.BTW, he also has mucho patents on his sorting algorithms.

On Sun, Apr 24, 2022 at 1:37 PM Lenore Mullin @.***> wrote: That’s because it was Luther’s idea not Kens. That’s why it’s not in kens book .

On Sun, Apr 24, 2022 at 1:21 PM Walter Spector @.***> wrote:

  LOL!  Yes, I learned a bit about APL back in college (on a
  DECsystem-10).  My copy of the classic Sandra Pakin
  APL/360 manual from those days uses the terms "grade up"
  and "grade down" for the respective operators.  So I
  thought it was fun that the HPF group used the same for
  their functions.  It is also interesting that HPF 1 only
  had the grade functions.  HPF 2.0 added the sort
  functions.

  I also have a copy of Ken Iversons "A Programming
  Language".  It has quite a lot of prose on ranking and
  sorting, but doesn't specifically use those terms.

  Walter

  -----Original Message-----
  From: j3-fortran/fortran_proposals
  Sent: Apr 24, 2022 10:00 AM
  To: j3-fortran/fortran_proposals
  Cc: Walter Spector , Author
  Subject: Re: [j3-fortran/fortran_proposals] Add simple
  sorting intrinsics (Issue #258)

  Mathematical definitions are in my dissertation. If you’d
  like to speak to the original designer and implementor
  grade up and down in APL It is Luther Woodrum and he can
  be reached at
  ***@***.*** ***@***.***)
  —
  Reply to this email directly, view it on GitHub(

https://github.com/j3-fortran/fortran_proposals/issues/258#issuecomment-11 07878967), or unsubscribe( https://github.com/notifications/unsubscribe-auth/ABCNQO35Q4BDQOVONHV2BV3V GV44TANCNFSM5UGOXWPQ). You are receiving this because you authored the thread.Message ID:

  —
  Reply to this email directly, view it on GitHub, or
  unsubscribe.
  You are receiving this because

youcommented.[ABVSNFEJ7TVCTOPYCEAQSIDVGV7LFA5CNFSM5UGOXWP2YY3PNVWWK3TUL52HS4DF VREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOIIEPFVA.gif] Message ID: @.***>

-- "Great spirits have always encountered violent opposition from mediocre minds" - Albert Einstein

-- "Great spirits have always encountered violent opposition from mediocre minds" - Albert Einstein

-- "Great spirits have always encountered violent opposition from mediocre minds" - Albert Einstein

womenflyplanes commented 2 years ago

Bye the way, how long has fortran had multidimensional arrays? LW

On Mon, 25 Apr 2022, Lenore Mullin wrote:

Exactly!

On Mon, Apr 25, 2022 at 8:40 AM Luther Woodrum @.***> wrote: That's very funny. I was the one who first implemented mulidimensionaional arrays of more than two. All the ones before that were only for matrices, two dimensions.

  I implemented 7 dimensions.

  LW

  On Sun, 24 Apr 2022, Lenore Mullin wrote:

  > Ken never had indexing either. Luther was the first to
  introduce any kind of
  > indexing in APL.BTW, he also has mucho patents on his sorting
  algorithms.
  >
  > On Sun, Apr 24, 2022 at 1:37 PM Lenore Mullin
  ***@***.***>
  > wrote:
  >       That’s because it was Luther’s idea not Kens.
  > That’s why it’s not in kens book .
  >
  >
  > On Sun, Apr 24, 2022 at 1:21 PM Walter Spector
  > ***@***.***> wrote:
  >
  >       LOL!  Yes, I learned a bit about APL back in college (on
  a
  >       DECsystem-10).  My copy of the classic Sandra Pakin
  >       APL/360 manual from those days uses the terms "grade up"
  >       and "grade down" for the respective operators.  So I
  >       thought it was fun that the HPF group used the same for
  >       their functions.  It is also interesting that HPF 1 only
  >       had the grade functions.  HPF 2.0 added the sort
  >       functions.
  >        
  >       I also have a copy of Ken Iversons "A Programming
  >       Language".  It has quite a lot of prose on ranking and
  >       sorting, but doesn't specifically use those terms.
  >        
  >       Walter
  >        
  >       -----Original Message-----
  >       From: j3-fortran/fortran_proposals
  >       Sent: Apr 24, 2022 10:00 AM
  >       To: j3-fortran/fortran_proposals
  >       Cc: Walter Spector , Author
  >       Subject: Re: [j3-fortran/fortran_proposals] Add simple
  >       sorting intrinsics (Issue #258)
  >        
  >        
  >       Mathematical definitions are in my dissertation. If
  you’d
  >       like to speak to the original designer and implementor
  >       grade up and down in APL It is Luther Woodrum and he can
  >       be reached at
  >       ***@***.*** ***@***.***)
  >       —
  >       Reply to this email directly, view it onGitHub(https://github.com/j3-fortran/fortran_proposals/issues/258#issuecomm
  ent-11
  >       07878967), orunsubscribe(https://github.com/notifications/unsubscribe-auth/ABCNQO35Q4BDQ
  OVONHV2BV3V
  >       GV44TANCNFSM5UGOXWPQ).
  >       You are receiving this because you authored the
  >       thread.Message ID:
  >
  >        
  >
  >       —
  >       Reply to this email directly, view it on GitHub, or
  >       unsubscribe.
  >       You are receiving this becauseyoucommented.[ABVSNFEJ7TVCTOPYCEAQSIDVGV7LFA5CNFSM5UGOXWP2YY3PNVWWK3TUL52HS
  4DF
  >       VREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOIIEPFVA.gif]
  >       Message ID:
  >     
  ***@***.***>
  >
  > --
  > "Great spirits have always encountered violent opposition from
  > mediocre minds" - Albert Einstein
  >
  >
  >
  > --
  > "Great spirits have always encountered violent opposition from
  mediocre
  > minds" - Albert Einstein
  >
  >

-- "Great spirits have always encountered violent opposition from mediocre minds" - Albert Einstein

certik commented 2 years ago

This seems a duplicate of https://github.com/j3-fortran/fortran_proposals/issues/101.

Update: the #101 is not a duplicate, but a similar proposal. See the clarification below.

w6ws commented 2 years ago

-----Original Message----- From: j3-fortran/fortran_proposals Sent: May 7, 2022 5:49 PM To: j3-fortran/fortran_proposals Cc: Walter Spector , Author Subject: Re: [j3-fortran/fortran_proposals] Add simple sorting intrinsics (Issue #258)     This seems a duplicate of #101 (https://github.com/j3-fortran/fortran_proposals/issues/101).

  Yes and no.  The stdlib procedures ORD_SORT, SORT_INDEX, and SORT, implemented in #101 are a great start.  But as mentioned, my proposal is a little different.  In particular:   1.) Functional form.  This would allow use in expressions rather than subroutine calls.  It also avoids the need to allocate and make a copy of the input array in the case where the original unsorted input data needs to be maintained as is.   2.) Explicit GRADE functions - SORT_INDEX does an in-place sort of its input argument and also returns the index array.  Again very often reordering the input array is not wanted.  Just the indices for use in later permutations.  (For example, obtaining the index array for keys in arrays of derived types.)  And again functional form would allow use in expressions.   3.) Encoding the sort order in the entry point name.  This eliminates run-time checking of required order.  While it is a cheap test, in practice in my 40+ years of programming, one tends to know which direction is desired at compile time.  Though in the case of GRADE functions, there should probably be an optional argument to maintain stability or not.   Additionally thread #101 has some later messages about search procedures such as binary search.  Over the  years I've encountered numerous examples of Fortran applications with homegrown binary search procedures.  However they are easy enough to write that I don't have strong feelings about including them or not.  In any event, they sound be under a different proposal thread.   If I should add these comments to #101 instead, then that would be fine.   Walter

certik commented 2 years ago

@w6ws, let's keep this issue here, separate from #101. I can see that they are similar, but distinct proposals, so let's keep both issues open. I wasn't sure if you were aware of the work at #101, but it's now clarified.

gklimowicz commented 2 years ago

Bye the way, how long has fortran had multidimensional arrays? LW

Since Fortran I in 1956, if you mean 1, 2, or 3-dimensional arrays. I believe that was the case for Fortan II and Fortran 66.

Fortran 77 upped the limit to 7 dimensions, which appears to be the limit in Fortran 90, 95, and 2003.

Fortran 2008 increased the limit to 15 dimensions, but as the sum of dimensions and co-dimensions of an array (or coarray).

womenflyplanes commented 1 year ago

forwarding to Damian who may know.

On Mon, Apr 25, 2022 at 10:14 AM Luther Woodrum @.***> wrote:

Bye the way, how long has fortran had multidimensional arrays? LW

On Mon, 25 Apr 2022, Lenore Mullin wrote:

Exactly!

On Mon, Apr 25, 2022 at 8:40 AM Luther Woodrum @.***> wrote: That's very funny. I was the one who first implemented mulidimensionaional arrays of more than two. All the ones before that were only for matrices, two dimensions.

  I implemented 7 dimensions.

  LW

  On Sun, 24 Apr 2022, Lenore Mullin wrote:

  > Ken never had indexing either. Luther was the first to
  introduce any kind of
  > indexing in APL.BTW, he also has mucho patents on his sorting
  algorithms.
  >
  > On Sun, Apr 24, 2022 at 1:37 PM Lenore Mullin
  ***@***.***>
  > wrote:
  >       That’s because it was Luther’s idea not Kens.
  > That’s why it’s not in kens book .
  >
  >
  > On Sun, Apr 24, 2022 at 1:21 PM Walter Spector
  > ***@***.***> wrote:
  >
  >       LOL!  Yes, I learned a bit about APL back in college (on
  a
  >       DECsystem-10).  My copy of the classic Sandra Pakin
  >       APL/360 manual from those days uses the terms "grade up"
  >       and "grade down" for the respective operators.  So I
  >       thought it was fun that the HPF group used the same for
  >       their functions.  It is also interesting that HPF 1 only
  >       had the grade functions.  HPF 2.0 added the sort
  >       functions.
  >
  >       I also have a copy of Ken Iversons "A Programming
  >       Language".  It has quite a lot of prose on ranking and
  >       sorting, but doesn't specifically use those terms.
  >
  >       Walter
  >
  >       -----Original Message-----
  >       From: j3-fortran/fortran_proposals
  >       Sent: Apr 24, 2022 10:00 AM
  >       To: j3-fortran/fortran_proposals
  >       Cc: Walter Spector , Author
  >       Subject: Re: [j3-fortran/fortran_proposals] Add simple
  >       sorting intrinsics (Issue #258)
  >
  >
  >       Mathematical definitions are in my dissertation. If
  you’d
  >       like to speak to the original designer and implementor
  >       grade up and down in APL It is Luther Woodrum and he can
  >       be reached at
  >       ***@***.*** ***@***.***)
  >       —
  >       Reply to this email directly, view it onGitHub(

https://github.com/j3-fortran/fortran_proposals/issues/258#issuecomm ent-11

  07878967), orunsubscribe(

https://github.com/notifications/unsubscribe-auth/ABCNQO35Q4BDQ OVONHV2BV3V GV44TANCNFSM5UGOXWPQ). You are receiving this because you authored the thread.Message ID:

  —
  Reply to this email directly, view it on GitHub, or
  unsubscribe.
  You are receiving this

becauseyoucommented.[ABVSNFEJ7TVCTOPYCEAQSIDVGV7LFA5CNFSM5UGOXWP2YY3PNVWWK3TUL52HS 4DF VREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOIIEPFVA.gif] Message ID:

@.***>

-- "Great spirits have always encountered violent opposition from mediocre minds" - Albert Einstein

-- "Great spirits have always encountered violent opposition from mediocre minds" - Albert Einstein

-- "Great spirits have always encountered violent opposition from mediocre minds" - Albert Einstein

-- "Great spirits have always encountered violent opposition from mediocre minds" - Albert Einstein