04-29-2017, 04:22 PM
When both operands of .* or ./ are vectors of the same dimensions, both functions work accordingly:
[2,4] .* [2,4] → [4,16]
[2,4] ./ [2,4] → [1,1]
But when the first operand is a number they behave in a different way:
4 .* [2,4] → [8,16]
4 ./ [2,4] → Error: Invalid dimension
In this case the operator * (without the dot), also works:
4 * [2,4] → [8,16]
As a workaround for 4 ./ [2,4] one can use:
4 .* [2,4] .^ (-1) → [2,1]
4 * [2,4] .^ (-1) → [2,1]
Is this the intended behavior, or should 4 ./ [2,4] also return [2,1] ?
[2,4] .* [2,4] → [4,16]
[2,4] ./ [2,4] → [1,1]
But when the first operand is a number they behave in a different way:
4 .* [2,4] → [8,16]
4 ./ [2,4] → Error: Invalid dimension
In this case the operator * (without the dot), also works:
4 * [2,4] → [8,16]
As a workaround for 4 ./ [2,4] one can use:
4 .* [2,4] .^ (-1) → [2,1]
4 * [2,4] .^ (-1) → [2,1]
Is this the intended behavior, or should 4 ./ [2,4] also return [2,1] ?