I can vectorize a function using the dot notation:
a = Vector(0:10) .* 4
As in plenty of examples I read the dot comes prior to the asterisk. However, this does not work in the following case:
Complex.(a,a)
Here the dot suddenly goes behind the function name.
Is this intended? And is there a rule?
For functions, the dot always goes behind the function name.
For operators, like *
or +
for example, the dot goes before the operator. However, you can enclose the operator in parentheses and suffix the dot.
To make this difference even more explicit, consider this example where we apply "multiply" with function call syntax:
x = rand(2,2)
sqrt.(x)
.*(x,x)
(*).(x,x)
x .* x
The last three commands all do the same thing.
See the corresponding sections of the Julia documentation for more: Dot Syntax for Vectorizing Functions and Vectorized "dot" operators.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With