Different behavior of ./ and .* with vectors [SOLVED]
04-29-2017, 04:22 PM (This post was last modified: 02-02-2018 08:44 PM by JMB.)
Post: #1
 JMB Member Posts: 98 Joined: Jan 2016
Different behavior of ./ and .* with vectors [SOLVED]
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] ?
 « Next Oldest | Next Newest »

 Messages In This Thread Different behavior of ./ and .* with vectors [SOLVED] - JMB - 04-29-2017 04:22 PM RE: Different behavior of ./ and .* with vectors - Tim Wessman - 05-01-2017, 04:19 PM RE: Different behavior of ./ and .* with vectors - JMB - 05-01-2017, 05:34 PM RE: Different behavior of ./ and .* with vectors - compsystems - 05-02-2017, 09:11 PM RE: Different behavior of ./ and .* with vectors - JMB - 02-02-2018, 08:44 PM

User(s) browsing this thread: 1 Guest(s)