[Numpy-discussion] Confused by spec of numpy.linalg.solve
njs at pobox.com
Tue Apr 1 11:25:01 EDT 2014
On Tue, Apr 1, 2014 at 3:57 PM, Sebastian Berg
<sebastian at sipsolutions.net> wrote:
> If `a` has exactly one dimension more then `b`, the first case is used.
> Otherwise (..., M, K) is used instead. To make sure you always get the
> expected result, it may be best to make sure that the number of
> broadcasting (...) dimensions of `a` and `b` are identical (I am not
> sure if you expect this to be the case or not). The shape itself does
> not matter, only the (relative) number of dimensions does for the
> decision which of the two signatures is used.
Oh, really? This seems really unfortunate -- AFAICT it makes it
impossible to write a generic broadcasting matrix-solve or
vector-solve :-/ (except by explicitly checking shapes and prepending
ones by hand, more or less doing the broadcasting manually). Surely it
would be better to use PEP 467 style broadcasting, where the only
special case is if `b` has exactly 1 dimension?
Nathaniel J. Smith
Postdoctoral researcher - Informatics - University of Edinburgh
More information about the NumPy-Discussion