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] ?
05-01-2017, 04:19 PM
Post: #2
 Tim Wessman Senior Member Posts: 2,293 Joined: Dec 2013
RE: Different behavior of ./ and .* with vectors
Thanks, we'll put it on the list to investigate.

TW

Although I work for HP, the views and opinions I post here are my own.
05-01-2017, 05:34 PM
Post: #3
 JMB Member Posts: 98 Joined: Jan 2016
RE: Different behavior of ./ and .* with vectors
Thank you for your time, Tim!

I have noticed now that 4 ./ [2,4] returns the expected result [2,1] in CAS mode.
05-02-2017, 09:11 PM (This post was last modified: 05-03-2017 06:39 PM by compsystems.)
Post: #4
 compsystems Senior Member Posts: 1,379 Joined: Dec 2013
RE: Different behavior of ./ and .* with vectors

the two arguments must be an array although the math kernel can expand functionality with scalars

array vs matrix(linear algebra) operations

https://www.mathworks.com/help/matlab/ma...tions.html

HP50 & HPPRIME CAS MODE

HP50

HPPRIME CAS MODE
[1,2] .* [3,4] RETURNS [3,8]

4 ./ [2,4] -> [2,1]
[4] ./ [2,4] -> [2] /!\ Resize to a smaller size
[2,4] ./ [4] -> [1/2]

4 .* ([2,4] .^ -1) -> [2,1]

4./[2,4] -> 4.0 / [2,4] -> 4./[2,4] ?
Without spaces also should operate to each element, as some point operations are equivalent to natural operators like [+] [-] [/]
02-02-2018, 08:44 PM
Post: #5
 JMB Member Posts: 98 Joined: Jan 2016
RE: Different behavior of ./ and .* with vectors
Corrected in firmware 13333.

Thanks to the HP Prime Team!
 « Next Oldest | Next Newest »