Skip to content

Commit

Permalink
clarify manual description of array assignment. fixes JuliaLang#4727
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Nov 8, 2013
1 parent 8b33ba9 commit 09369aa
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions doc/manual/arrays.rst
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,8 @@ The result X generally has dimensions
``(i_1, i_2, ..., i_n)`` of X containing the value
``A[I_1[i_1], I_2[i_2], ..., I_n[i_n]]``. Trailing dimensions indexed with
scalars are dropped. For example, the dimensions of ``A[I, 1]`` will be
``(length(I),)``. The size of a dimension indexed by a boolean vector
will be the number of true values in the vector (they behave as if they were
transformed with ``find``).
``(length(I),)``. Boolean vectors are first transformed with ``find``; the size of
a dimension indexed by a boolean vector will be the number of true values in the vector.

Indexing syntax is equivalent to a call to ``getindex``::

Expand Down Expand Up @@ -208,9 +207,13 @@ where each I\_k may be:
3. An arbitrary integer vector, including the empty vector ``[]``
4. A boolean vector

The size of X should be ``(length(I_1), length(I_2), ..., length(I_n))``, and
the value in location ``(i_1, i_2, ..., i_n)`` of A is overwritten with
the value ``X[I_1[i_1], I_2[i_2], ..., I_n[i_n]]``.
If ``X`` is an array, its size must be ``(length(I_1), length(I_2), ..., length(I_n))``,
and the value in location ``i_1, i_2, ..., i_n`` of ``A`` is overwritten with
the value ``X[I_1[i_1], I_2[i_2], ..., I_n[i_n]]``. If ``X`` is not an array, its
value is written to all referenced locations of ``A``.

A boolean vector used as an index behaves as in ``getindex`` (it is first transformed
with ``find``).

Index assignment syntax is equivalent to a call to ``setindex!``::

Expand Down

0 comments on commit 09369aa

Please sign in to comment.