Skip to content

Commit

Permalink
docs for unary dot operators
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj committed Jan 26, 2017
1 parent 2d49f82 commit 26a71e0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Language changes
the `broadcast` call `(⨳).(a, b)`. Hence, one no longer defines methods
for `.*` etcetera. This also means that "dot operations" automatically
fuse into a single loop, along with other dot calls `f.(x)`. ([#17623])
Similarly for unary operators ([#20249]).

* Newly defined methods are no longer callable from the same dynamic runtime
scope they were defined in ([#17057]).
Expand Down
2 changes: 1 addition & 1 deletion doc/src/manual/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ overwriting `X` with `sin.(Y)` in-place. If the left-hand side is an array-index
e.g. `X[2:end] .= sin.(Y)`, then it translates to `broadcast!` on a `view`, e.g. `broadcast!(sin, view(X, 2:endof(X)), Y)`,
so that the left-hand side is updated in-place.
Operators like `.*` are handled with the same mechanism:
Binary (or unary) operators like `.+` are handled with the same mechanism:
they are equivalent to `broadcast` calls and are fused with other nested "dot" calls.
`X .+= Y` etcetera is equivalent to `X .= X .+ Y` and results in a fused in-place assignment;
see also [dot operators](@ref man-dot-operators).
Expand Down
4 changes: 3 additions & 1 deletion doc/src/manual/mathematical-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ to perform `^` element-by-element on arrays. For example,
`[1,2,3] ^ 3` is not defined, since there is no standard
mathematical meaning to "cubing" an array, but `[1,2,3] .^ 3`
is defined as computing the elementwise
(or "vectorized") result `[1^3, 2^3, 3^3]`.
(or "vectorized") result `[1^3, 2^3, 3^3]`. Similarly for unary
operators like `!` or ``, there is a corresponding `.√` that
applies the operator elementwise.

More specifically, `a .^ b` is parsed as the ["dot" call](@ref man-vectorized)
`(^).(a,b)`, which performs a [broadcast](@ref Broadcasting) operation:
Expand Down

0 comments on commit 26a71e0

Please sign in to comment.