1
1
#:include "common.fypp"
2
+ #:set IRS_KINDS_TYPES = INT_KINDS_TYPES + REAL_KINDS_TYPES + STRING_KINDS_TYPES
2
3
3
4
!! Licensing:
4
5
!!
@@ -326,11 +327,11 @@ module stdlib_sorting
326
327
327
328
public char_sort_index
328
329
329
- public string_ord_sort
330
+ public string_type_ord_sort
330
331
331
- public string_sort
332
+ public string_type_sort
332
333
333
- public string_sort_index
334
+ public string_type_sort_index
334
335
335
336
interface ord_sort
336
337
!! Version: experimental
@@ -346,29 +347,18 @@ module stdlib_sorting
346
347
!! sorted data, having O(N) performance on uniformly non-increasing or
347
348
!! non-decreasing data.
348
349
349
- #:for k1 in INT_KINDS
350
+ #:for k1, t1 in IRS_KINDS_TYPES
350
351
module subroutine ${k1}$_ord_sort( array, work )
351
352
!! Version: experimental
352
353
!!
353
- !! `${k1}$_ord_sort( array )` sorts the input `ARRAY` of type `INTEGER(${k1}$) `
354
+ !! `${k1}$_ord_sort( array )` sorts the input `ARRAY` of type `${t1}$ `
354
355
!! using a hybrid sort based on the `'Rust" sort` algorithm found in `slice.rs`
355
- integer(${k1}$) , intent(inout) :: array(0:)
356
- integer(${k1}$) , intent(inout), optional :: work(0:)
356
+ ${t1}$ , intent(inout) :: array(0:)
357
+ ${t1}$ , intent(inout), optional :: work(0:)
357
358
end subroutine ${k1}$_ord_sort
358
359
359
360
#:endfor
360
361
361
- #:for k1 in REAL_KINDS
362
- module subroutine ${k1}$_ord_sort( array, work )
363
- !! Version: experimental
364
- !!
365
- !! `${k1}$_ord_sort( array )` sorts the input `ARRAY` of type `REAL(${k1}$)`
366
- !! using a hybrid sort based on the `'Rust" sort` algorithm found in `slice.rs`
367
- real(${k1}$), intent(inout) :: array(0:)
368
- real(${k1}$), intent(inout), optional :: work(0:)
369
- end subroutine ${k1}$_ord_sort
370
-
371
- #:endfor
372
362
module subroutine char_ord_sort( array, work )
373
363
!! Version: experimental
374
364
!!
@@ -378,15 +368,6 @@ module stdlib_sorting
378
368
character(len=len(array)), intent(inout), optional :: work(0:)
379
369
end subroutine char_ord_sort
380
370
381
- module subroutine string_ord_sort( array, work )
382
- !! Version: experimental
383
- !!
384
- !! `char_ord_sort( array )` sorts the input `ARRAY` of type `CHARACTER(*)`
385
- !! using a hybrid sort based on the `'Rust" sort` algorithm found in `slice.rs`
386
- type(string_type), intent(inout) :: array(0:)
387
- type(string_type), intent(inout), optional :: work(0:)
388
- end subroutine string_ord_sort
389
-
390
371
end interface ord_sort
391
372
392
373
interface sort
@@ -395,30 +376,16 @@ module stdlib_sorting
395
376
!! The generic subroutine interface implementing the `SORT` algorithm, based
396
377
!! on the `introsort` of David Musser.
397
378
398
- #:for k1 in INT_KINDS
399
- pure module subroutine ${k1}$_sort( array )
400
- !! Version: experimental
401
- !!
402
- !! `${k1}$_sort( array )` sorts the input `ARRAY` of type `INTEGER(${k1}$)`
403
- !! using a hybrid sort based on the `introsort` of David Musser.
404
- !! The algorithm is of order O(N Ln(N)) for all inputs.
405
- !! Because it relies on `quicksort`, the coefficient of the O(N Ln(N))
406
- !! behavior is small for random data compared to other sorting algorithms.
407
- integer(${k1}$), intent(inout) :: array(0:)
408
- end subroutine ${k1}$_sort
409
-
410
- #:endfor
411
-
412
- #:for k1 in REAL_KINDS
379
+ #:for k1, t1 in IRS_KINDS_TYPES
413
380
pure module subroutine ${k1}$_sort( array )
414
381
!! Version: experimental
415
382
!!
416
- !! `${k1}$_sort( array )` sorts the input `ARRAY` of type `REAL(${k1}$) `
383
+ !! `${k1}$_sort( array )` sorts the input `ARRAY` of type `${t1}$ `
417
384
!! using a hybrid sort based on the `introsort` of David Musser.
418
385
!! The algorithm is of order O(N Ln(N)) for all inputs.
419
386
!! Because it relies on `quicksort`, the coefficient of the O(N Ln(N))
420
387
!! behavior is small for random data compared to other sorting algorithms.
421
- real(${k1}$) , intent(inout) :: array(0:)
388
+ ${t1}$ , intent(inout) :: array(0:)
422
389
end subroutine ${k1}$_sort
423
390
424
391
#:endfor
@@ -434,17 +401,6 @@ module stdlib_sorting
434
401
character(len=*), intent(inout) :: array(0:)
435
402
end subroutine char_sort
436
403
437
- pure module subroutine string_sort( array )
438
- !! Version: experimental
439
- !!
440
- !! `string_sort( array )` sorts the input `ARRAY` of type `STRING_TYPE`
441
- !! using a hybrid sort based on the `introsort` of David Musser.
442
- !! The algorithm is of order O(N Ln(N)) for all inputs.
443
- !! Because it relies on `quicksort`, the coefficient of the O(N Ln(N))
444
- !! behavior is small for random data compared to other sorting algorithms.
445
- type(string_type), intent(inout) :: array(0:)
446
- end subroutine string_sort
447
-
448
404
end interface sort
449
405
450
406
interface sort_index
@@ -458,41 +414,24 @@ module stdlib_sorting
458
414
!! non-decreasing sort, but if the optional argument `REVERSE` is present
459
415
!! with a value of `.TRUE.` the indices correspond to a non-increasing sort.
460
416
461
- #:for k1 in INT_KINDS
417
+ #:for k1, t1 in IRS_KINDS_TYPES
462
418
module subroutine ${k1}$_sort_index( array, index, work, iwork, &
463
419
reverse )
464
420
!! Version: experimental
465
421
!!
466
- !! `${k1}$_sort_index( array )` sorts an input `ARRAY` of type `INTEGER(${k1}$) `
422
+ !! `${k1}$_sort_index( array )` sorts an input `ARRAY` of type `${t1}$ `
467
423
!! using a hybrid sort based on the `'Rust" sort` algorithm found in `slice.rs`
468
424
!! and returns the sorted `ARRAY` and an array `INDEX of indices in the
469
425
!! order that would sort the input `ARRAY` in the desired direction.
470
- integer(${k1}$) , intent(inout) :: array(0:)
426
+ ${t1}$ , intent(inout) :: array(0:)
471
427
integer(int_size), intent(inout) :: index(0:)
472
- integer(${k1}$) , intent(inout), optional :: work(0:)
428
+ ${t1}$ , intent(inout), optional :: work(0:)
473
429
integer(int_size), intent(inout), optional :: iwork(0:)
474
430
logical, intent(in), optional :: reverse
475
431
end subroutine ${k1}$_sort_index
476
432
477
433
#:endfor
478
434
479
- #:for k1 in REAL_KINDS
480
- module subroutine ${k1}$_sort_index( array, index, work, iwork, &
481
- reverse )
482
- !! Version: experimental
483
- !!
484
- !! `${k1}$_sort_index( array )` sorts an input `ARRAY` of type `REAL(${k1}$)`
485
- !! using a hybrid sort based on the `'Rust" sort` algorithm found in `slice.rs`
486
- !! and returns the sorted `ARRAY` and an array `INDEX of indices in the
487
- !! order that would sort the input `ARRAY` in the desired direction.
488
- real(${k1}$), intent(inout) :: array(0:)
489
- integer(int_size), intent(inout) :: index(0:)
490
- real(${k1}$), intent(inout), optional :: work(0:)
491
- integer(int_size), intent(inout), optional :: iwork(0:)
492
- logical, intent(in), optional :: reverse
493
- end subroutine ${k1}$_sort_index
494
-
495
- #:endfor
496
435
module subroutine char_sort_index( array, index, work, iwork, &
497
436
reverse )
498
437
!! Version: experimental
@@ -508,21 +447,6 @@ module stdlib_sorting
508
447
logical, intent(in), optional :: reverse
509
448
end subroutine char_sort_index
510
449
511
- module subroutine string_sort_index( array, index, work, iwork, &
512
- reverse )
513
- !! Version: experimental
514
- !!
515
- !! `string_sort_index( array )` sorts an input `ARRAY` of type `STRING_TYPE`
516
- !! using a hybrid sort based on the `'Rust" sort` algorithm found in `slice.rs`
517
- !! and returns the sorted `ARRAY` and an array `INDEX of indices in the
518
- !! order that would sort the input `ARRAY` in the desired direction.
519
- type(string_type), intent(inout) :: array(0:)
520
- integer(int_size), intent(inout) :: index(0:)
521
- type(string_type), intent(inout), optional :: work(0:)
522
- integer(int_size), intent(inout), optional :: iwork(0:)
523
- logical, intent(in), optional :: reverse
524
- end subroutine string_sort_index
525
-
526
450
end interface sort_index
527
451
528
452
0 commit comments