diff --git a/NEWS.md b/NEWS.md index a899202425e93c..7e11d0c110132c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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]). diff --git a/doc/src/manual/functions.md b/doc/src/manual/functions.md index de36347e839ec6..2d3b4caa41cf0d 100644 --- a/doc/src/manual/functions.md +++ b/doc/src/manual/functions.md @@ -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). diff --git a/doc/src/manual/mathematical-operations.md b/doc/src/manual/mathematical-operations.md index e62b99b6408c1c..07fa4948d653c9 100644 --- a/doc/src/manual/mathematical-operations.md +++ b/doc/src/manual/mathematical-operations.md @@ -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: