Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Thank you for this PR @jvdp1. I agree with @jalvesz and like the Regarding your questions:
These arguments:
could become ${t1}$, intent(inout) :: sorted_array(0:)
${ti}$, intent(inout) :: adjoint_list(0:) to signal that sorting is performed based on the first argument. |
src/stdlib_sorting.fypp Outdated
!! https://.com/rust-lang/rust/blob/90eb44a5897c39e3dff9c7e48e3973671dcd9496/src/liballoc/slice.rs#L2159 | ||
!! but modified to return an array of indices that would provide a stable | ||
!! sort of the rank one `ARRAY` input. | ||
!! ([Specification](../page/specs/stdlib_sorting.html#sort_adj-creates-an-array-of-sorting-indices-for-an-input-array-while-also-sorting-the-array)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be updated
integer, allocatable :: array(:) | ||
real, allocatable :: adjoint(:) | ||
array = [5, 4, 3, 1, 10, 4, 9] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great example @jvdp1. Could it be made into a test as well? The test would check that array(i)>=array(i-1)
, and that nint(adjoint(i),kind=${ik}$)==array(i)
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Pending to add one test program, I think this is ready to merge.
@perazz @jvdp1 for the test program, maybe something like one of the tests I wrote for the sparse matrices could work?: subroutine test_coo2ordered(error)
!> Error handling
type(error_type), allocatable, intent(out) :: error
type(COO_sp_type) :: COO
integer :: row(12), col(12)
real :: data(12)
row = [1,1,1,2,2,3,2,2,2,3,3,4]
col = [2,3,4,3,4,4,3,4,5,4,5,5]
data = 1.0
call from_ijv(COO,row,col,data)
call coo2ordered(COO,sort_data=.true.)
call check(error, COO%nnz < 12 .and. COO%nnz == 9 )
if (allocated(error)) return
call check(error, all(COO%data==[1,1,1,2,2,1,2,1,1]) )
if (allocated(error)) return
call check(error, all(COO%index(1,:)==[1,1,1,2,2,2,3,3,4]) )
if (allocated(error)) return
call check(error, all(COO%index(2,:)==[2,3,4,3,4,5,4,5,5]) )
if (allocated(error)) return
end subroutine Applying the sorting to |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Federico Perini <[email protected]>
Addition of
sort_adj
to sort an rank 1 array in the same order as an input array.It is basically an extension of the original
sort_index
procedure, by making the arrayindex
intent(inout)
, instead ofintent(out)
only.To be discussed:
sort_adj
, but I think another (more appropriate) name should be foundindex
: suggestions of a more appropriate name?sort_index
still valid/appropriate/useful?@jalvesz
sort_adj
could replace your internal sorting procedure in your sparse implementation. If not, I think it is still a nice addition tostdlib
.