Is A./B different from B.\A?
91 views (last 30 days)
Given two matrices, A and B, will A./B ever give a different answer from B.\A, or are these two expressions equivalent?
It seems that even for complex numbers they return the same thing. E.g.
>> A = sqrt(randn(3));
>> B = sqrt(randn(3));
>> isequal(A./B, B.\A)
ans = 1
James Tursa on 17 Jun 2015
I can't think of any reason why one would ever get different results for numeric types. I suppose there might be speed differences if one form used multi-threading and the other form didn't, but in tests I just ran they both appeared to take about the same amount of time.
User defined classes could of course overload them differently.
More Answers (2)
Alberto on 17 Jun 2015
Both are pointwise, but A./B divides every element in A by the same element in B. A.\B divides every element in B by the same element in A.
H. Sh. G. on 28 Sep 2021
Hi every body.
I wonder what kind of calculations the division of a matrix (X) by a row vector (y), i.e. X/y, does, where both have the same number of columns.
The result is a column vector of the same number of rows that X has.
Recall that X./y divides all elements of each column in X by the element of y in the same column, resulting in a matrix with the same size of X.