<p dir="ltr">On May 22, 2015 11:00 AM, "Alexander Belopolsky" <<a href="mailto:ndarray@mac.com">ndarray@mac.com</a>> wrote:<br>
><br>
><br>
> On Thu, May 21, 2015 at 9:37 PM, Nathaniel Smith <<a href="mailto:njs@pobox.com">njs@pobox.com</a>> wrote:<br>
> ><br>
> > .. there's been some discussion of the possibility of<br>
><br>
> > adding specialized gufuncs for broadcasted vector-vector,<br>
> > vector-matrix, matrix-vector multiplication, which wouldn't do the<br>
> > magic vector promotion that dot and @ do.<br>
><br>
><br>
> This would be nice. What I would like to see is some consistency between multi-matrix<br>
> support in linalg methods and dot.<br>
><br>
> For example, when A is a matrix and b is a vector and<br>
><br>
> a = linalg.solve(A, b)<br>
><br>
> then<br>
><br>
> dot(A, a) returns b, but if either or both A and b are stacks, this invariant does not hold. I would like<br>
> to see a function (say xdot) that I can use instead of dot and have xdot(A, a) return b whenever a = linalg.solve(A, b).</p>
<p dir="ltr">I believe this equivalence holds if xdot(x, y) = x @ y, because solve() does follow the pep 465 semantics for shape handling. Or at least, it's intended to. Of course we will also expose pep 465 matmul semantics under some name that doesn't require the new syntax (probably not "xdot" though ;-)).</p>
<p dir="ltr">> Similarly, if w,v = linalg.eig(A), then dot(A,v) returns w * v, but only if A is 2d.</p>
<p dir="ltr">Again A @ v I believe does the right thing, though I'm not positive -- you might need a swapaxes or matvec or something. Let us know if you work it out :-).</p>
<p dir="ltr">Note that it still won't be equivalent to w * v because w * v doesn't broadcast the way you want :-). You need w[..., np.newaxis, :] * v, I think.</p>
<p dir="ltr">-n</p>
<p dir="ltr">><br>
><br>
> _______________________________________________<br>
> NumPy-Discussion mailing list<br>
> <a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
> <a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
><br>
</p>