Skip to content

Commit 6061806

Browse files
committed
devdocs: typesetting of pluralizations
1 parent 3a74065 commit 6061806

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

doc/devdocs/subarrays.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ SubArrays
88

99
Julia's ``SubArray`` type is a container encoding a "view" of a parent
1010
``AbstractArray``. This page documents some of the design principles
11-
and implementation of ``SubArrays``.
11+
and implementation of ``SubArray``\s.
1212

1313
Indexing: cartesian vs. linear indexing
1414
---------------------------------------
@@ -25,14 +25,14 @@ example, a 3d array ``A3`` can be indexed as ``A3[i,j]``, in which
2525
case ``i`` is interpreted as a cartesian index for the first
2626
dimension, and ``j`` is a linear index over dimensions 2 and 3.
2727

28-
For ``Arrays``, linear indexing appeals to the underlying storage
28+
For ``Array``\s, linear indexing appeals to the underlying storage
2929
format: an array is laid out as a contiguous block of memory, and
3030
hence the linear index is just the offset (+1) of the corresponding
3131
entry relative to the beginning of the array. However, this is not
32-
true for many other ``AbstractArrays``: examples include
32+
true for many other ``AbstractArray`` types: examples include
3333
``SparseMatrixCSC``, arrays that require some kind of computation
3434
(such as interpolation), and the type under discussion here,
35-
``SubArrays``. For these types, the underlying information is more
35+
``SubArray``. For these types, the underlying information is more
3636
naturally described in terms of cartesian indexes.
3737

3838
You can manually convert from a cartesian index to a linear index with
@@ -45,7 +45,7 @@ While converting from a cartesian index to a linear index is fast
4545
index to a cartesian index is very slow: it relies on the ``div``
4646
operation, which is one of the slowest low-level operations you can
4747
perform with a CPU. For this reason, any code that deals with
48-
``AbstractArrays`` is best designed in terms of cartesian, rather than
48+
``AbstractArray`` types is best designed in terms of cartesian, rather than
4949
linear, indexing.
5050

5151
Index replacement
@@ -57,7 +57,7 @@ Consider making 2d slices of a 3d array::
5757
S2 = slice(A, 5, :, 2:6)
5858

5959
``slice`` drops "singleton" dimensions (ones that are specified by an
60-
``Int``), so both ``S1`` and ``S2`` are two-dimensional ``SubArrays``.
60+
``Int``), so both ``S1`` and ``S2`` are two-dimensional ``SubArray``\s.
6161
Consequently, the natural way to index these is with ``S1[i,j]``. To
6262
extract the value from the parent array ``A``, the natural approach is
6363
to replace ``S1[i,j]`` with ``A[i,5,(2:6)[j]]`` and ``S2[i,j]`` with
@@ -83,7 +83,7 @@ of the type::
8383
stride1::Int # used only for linear indexing
8484
end
8585

86-
``SubArrays`` have 5 type parameters. The first two are the
86+
``SubArray`` has 5 type parameters. The first two are the
8787
standard element type and dimensionality. The next is the type of the
8888
parent ``AbstractArray``. The most heavily-used is the fourth
8989
parameter, a ``tuple`` of the types of the indexes for each dimension.
@@ -120,7 +120,7 @@ Because of this conversion, ``S3`` is three-dimensional.
120120
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
121121

122122
Performing index translation requires that you do different things for
123-
different types of ``SubArrays``. For example, for ``S1``, one needs
123+
different concrete ``SubArray`` types. For example, for ``S1``, one needs
124124
to apply the ``i,j`` indexes to the first and third dimensions of the
125125
parent array, whereas for ``S2`` one needs to apply them to the
126126
second and third. The simplest approach to indexing would be to do
@@ -148,7 +148,7 @@ The better approach is to dispatch to specific methods to handle each
148148
type of input. Note, however, that the number of distinct methods
149149
needed grows exponentially in the number of dimensions, and since
150150
Julia supports arrays of any dimension the number of methods required
151-
is in fact infinite. Fortunately, ``stagedfunctions`` allow one to
151+
is in fact infinite. Fortunately, ``stagedfunction``\s allow one to
152152
generate the necessary methods quite straightforwardly. The resulting
153153
code looks quite a lot like the runtime approach above, but all of the
154154
type analysis is performed at the time of method instantiation. For a
@@ -162,7 +162,7 @@ Linear indexing
162162

163163
Linear indexing can be implemented efficiently when the entire array
164164
has a single stride that separates successive elements. For
165-
``SubArrays``, the availability of efficient linear indexing is based
165+
``SubArray`` types, the availability of efficient linear indexing is based
166166
purely on the types of the indexes, and does not depend on values like
167167
the size of the array. It therefore can miss some cases in which the
168168
stride happens to be uniform::
@@ -205,7 +205,7 @@ decision based purely on types encoded in the parameters of the
205205
``SubArray``, ``S = sub(A, 2:2:4, :)`` cannot implement efficient
206206
linear indexing.
207207

208-
The last parameter of ``SubArrays``, ``LD``, encodes the highest
208+
The last parameter of ``SubArray``, ``LD``, encodes the highest
209209
dimension up to which elements are guaranteed to have uniform stride.
210210
When ``LD == length(I)``, the length of the ``indexes`` tuple,
211211
efficient linear indexing becomes possible.
@@ -240,7 +240,7 @@ indexing.
240240

241241
The main reason ``LD`` cannot always be inferred from the ``indexes`` tuple
242242
is because ``sub`` converts internal ``Int`` indexes into
243-
``UnitRanges``. Consequently it is important to encode "safe"
243+
``UnitRange``\s. Consequently it is important to encode "safe"
244244
dimensions of size 1 prior to conversion. Up to the ``LDth`` entry,
245245
we can be sure that any ``UnitRange`` was, in fact, an ``Integer``
246246
prior to conversion.

0 commit comments

Comments
 (0)