Skip to content

Commit a6b9b28

Browse files
committed
Update documentation
1 parent 9238cd0 commit a6b9b28

File tree

3 files changed

+76
-19
lines changed

3 files changed

+76
-19
lines changed

doc/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ which wrap the C++ library.
3131

3232
.. toctree::
3333
:maxdepth: 2
34-
:caption: Contents:
34+
:caption: Contents
3535

3636
introduction.rst
3737
modules.rst

doc/modules/algorithm.rst

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ The ``flc_algorithm`` module wraps C++ standard `<algorithm>`_ routines.
1212
Instead of taking pairs of iterators, the Flibcpp algorithm subroutines accept
1313
target-qualified 1-D arrays.
1414

15-
Algorithms that take comparators (e.g. sort) will be instantiated with function
16-
pointers that allow user functions to add arbitrary ordering by defining
17-
``bind(C)`` functions and calling with ``c_funloc(my_comparator)``.
15+
Algorithms that take comparators (e.g. sorting and searching) are instantiated
16+
with function pointers that allow user functions to add arbitrary ordering by
17+
defining ``bind(C)`` functions and calling with ``c_funloc(my_comparator)``.
1818

1919
Wherever possible, array indices are returned as Fortran 1-offset native
2020
integers, with the value 0 indicating off-the-end (e.g. "not found").
@@ -24,21 +24,31 @@ integers, with the value 0 indicating off-the-end (e.g. "not found").
2424
Sorting
2525
=======
2626

27-
All sorting functions
28-
29-
Sort
27+
sort
3028
----
3129

3230
Sorting and checking order is a single simple subroutine call::
3331

34-
use flc_algorithm, only : sort, is_sorted
32+
use flc_algorithm, only : sort
3533
implicit none
3634
integer, dimension(5) :: iarr = [ 2, 5, -2, 3, -10000]
37-
logical :: sortitude
3835

3936
call sort(iarr)
37+
38+
is_sorted
39+
---------
40+
41+
Checking the ordering of array is just as simple::
42+
43+
use flc_algorithm, only : is_sorted
44+
integer, dimension(5) :: iarr = [ 2, 5, -2, 3, -10000]
45+
logical :: sortitude
46+
4047
sortitude = is_sorted(iarr)
4148

49+
argsort
50+
-------
51+
4252
A routine that provides the indices that correspond to a sorted array, like
4353
Numpy's argsort_ ,
4454
takes an array to analyze and an empty array of integers to fill::
@@ -61,9 +71,13 @@ the index array is larger than the data, invalid entries will be filled with
6171
zero.
6272

6373
.. _argsort: https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.argsort.html
74+
6475
Searching
6576
=========
6677

78+
binary_search
79+
-------------
80+
6781
A binary search can be performed on sorted data to efficiently find an element
6882
in a range. If the element is not found, the function returns zero; otherwise,
6983
it returns the Fortran index of the array.
@@ -84,25 +98,54 @@ Example::
8498
idx = binary_search(iarr, 9) ! returns 6
8599
idx = binary_search(iarr, 10) ! returns 0
86100

101+
minmax_element
102+
--------------
103+
104+
TODO
87105

88106
Set operations
89107
==============
90108

91109
Sorted arrays can be manipulated as "sets," supporting unions, intersections,
92110
and differences. TODO.
93111

112+
includes
113+
--------
114+
115+
TODO
116+
117+
set_difference
118+
--------------
119+
120+
TODO
121+
122+
set_intersection
123+
----------------
124+
125+
TODO
126+
127+
set_symmetric_difference
128+
------------------------
129+
130+
TODO
131+
132+
set_union
133+
---------
134+
135+
TODO
136+
94137
Modifying
95138
=========
96139

97140
.. _modules_algorithm_shuffle:
98141

99-
Shuffle
142+
shuffle
100143
-------
101144

102-
The ``algorithm`` module depends on the ``random`` module so that it can use
103-
the supported random number generator to randomly reorder an array.
145+
The "shuffle" subroutine depends on the :ref:`modules_random` module so that it
146+
can use the supported random number generator to randomly reorder an array.
104147

105-
Unique
148+
unique
106149
------
107150

108151
TODO

doc/modules/random.rst

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,30 @@ Its interface is::
5151
module procedure new_Engine
5252
end interface
5353

54-
Normal distribution
55-
===================
54+
Distributions
55+
=============
5656

57-
Uniform integer distribution
58-
============================
57+
Distributions produce numerical values from the random bitstream provided by
58+
the Engine.
5959

60-
Uniform real distribution
61-
=========================
60+
normal_distribution
61+
-------------------
6262

63+
Fill the given array with Gaussian-distributed numbers generated using the
64+
given random number engine about the given mean value with the given standard
65+
deviation, which defaults to 1.
6366

67+
uniform_int_distribution
68+
------------------------
69+
70+
Fill the given array with uniformly distributed integers generated using the
71+
given random number engine, between the two bounds (inclusive on both sides).
72+
73+
uniform_real_distribution
74+
-------------------------
75+
76+
Fill the given array with uniformly distributed real numbers generated using the
77+
given random number engine, between the two bounds (inclusive on left side only).
6478

6579

6680
.. ############################################################################

0 commit comments

Comments
 (0)