The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
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
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] ?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Different behavior of ./ and .* with vectors [SOLVED] - JMB - 04-29-2017 04:22 PM



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