Skip to content

Commit bb45830

Browse files
committed
Fix documentation
1 parent cb13428 commit bb45830

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

doc/modules/algorithm.rst

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,23 @@ integers, with the value 0 indicating off-the-end (e.g. "not found").
2424
Sorting
2525
=======
2626

27+
All sorting functions
28+
29+
Sort
30+
----
31+
2732
Sorting and checking order is a single simple subroutine call::
2833

2934
use flc_algorithm, only : sort, is_sorted
3035
implicit none
3136
integer, dimension(5) :: iarr = [ 2, 5, -2, 3, -10000]
32-
logical :: result
37+
logical :: sortitude
3338

3439
call sort(iarr)
35-
result = is_sorted(iarr)
40+
sortitude = is_sorted(iarr)
3641

3742
A routine that provides the indices that correspond to a sorted array, like
38-
Numpy's [argsort](https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.argsort.html),
43+
Numpy's argsort_ ,
3944
takes an array to analyze and an empty array of integers to fill::
4045

4146
use flc_algorithm, only : argsort
@@ -45,7 +50,7 @@ takes an array to analyze and an empty array of integers to fill::
4550

4651
call argsort(iarr, idx)
4752
! This line prints a sorted array:
48-
write(*,*), iarr(idx)
53+
write(*,*) iarr(idx)
4954

5055
Note that the index array is always a ``C_INT``. On some compilers and
5156
platforms, this may be the same as native Fortran integer, but it's not
@@ -55,6 +60,7 @@ The ``data`` and ``idx`` arguments to ``argsort`` *must* be the same size. If
5560
the index array is larger than the data, invalid entries will be filled with
5661
zero.
5762

63+
.. _argsort: https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.argsort.html
5864
Searching
5965
=========
6066

@@ -68,15 +74,15 @@ Example::
6874

6975
use flc_algorithm, only : binary_search
7076
implicit none
71-
integer :: index
77+
integer :: idx
7278
integer, dimension(6) :: iarr = [ -5, 1, 1, 2, 4, 9]
7379

74-
index = binary_search(iarr, -100) ! returns 0
75-
index = binary_search(iarr, 1) ! returns 2
76-
index = binary_search(iarr, 2) ! returns 4
77-
index = binary_search(iarr, 3) ! returns 0
78-
index = binary_search(iarr, 9) ! returns 6
79-
index = binary_search(iarr, 10) ! returns 0
80+
idx = binary_search(iarr, -100) ! returns 0
81+
idx = binary_search(iarr, 1) ! returns 2
82+
idx = binary_search(iarr, 2) ! returns 4
83+
idx = binary_search(iarr, 3) ! returns 0
84+
idx = binary_search(iarr, 9) ! returns 6
85+
idx = binary_search(iarr, 10) ! returns 0
8086

8187

8288
Set operations

0 commit comments

Comments
 (0)